#include <QApplication>
#include <QQmlApplicationEngine>
#include <QGenericPlugin>
#include <QPluginLoader>
#include <QThreadPool>
#include <QFont>
#include <QHostAddress>
#include <QHostInfo>
#include <QQmlPropertyMap>
#include <QQmlContext>
#include <QNetworkAccessManager>
#include "path.h"
#include "applicationengine.h"
#include "java.h"
#include "api.h"
#include "urlquery.h"

static QJSValue help_qjsvalue_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{
    Q_UNUSED(engine)

    QJSValue help = scriptEngine->newObject();

    help.setProperty("WEB", "http://" + qApp->organizationDomain());
    help.setProperty("CONTACT", "范范");
    help.setProperty("MAILBOX", "awfan.cn@gmail.com");
    help.setProperty("MOBILE", "15958189624");
    help.setProperty("ADDRESS", "杭州市拱墅区");
    help.setProperty("APPNAME", QGuiApplication::applicationDisplayName());
#ifdef QT_DEBUG
    help.setProperty("SERVER", "192.168.10.242:8080");
#else
    help.setProperty("SERVER", "182.254.245.83:8080");
#endif
    return help;
}


int main(int argc, char *argv[])
{
    QGuiApplication::setApplicationName("车吧");
    QGuiApplication::setApplicationDisplayName("车吧");
    QGuiApplication::setOrganizationName("范范软件");
    QGuiApplication::setOrganizationDomain("www.awfan.cn");
    QGuiApplication::setWindowIcon(QIcon("qrc:/favicon.png"));
    QGuiApplication::setApplicationVersion(VERSION "." SVN_BUILD);
    QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

    QApplication application(argc, argv);

    ApplicationEngine engine;


    qmlRegisterSingletonType("fan.qt.complex", 1, 0, "G", help_qjsvalue_singletontype_provider);
    qmlRegisterSingletonType<Api>("fan.qt.complex", 1, 0, "A", Api_singletontype_provider);
    qmlRegisterSingletonType<Path>("fan.qt.complex", 1, 0, "P", Path_singletontype_provider);
    qmlRegisterSingletonType<UrlQuery>("fan.qt.complex", 1, 0, "U", UrlQuery_singletontype_provider);


    return engine.create();
}
